<?php

if(!function_exists('bob_detect_os')) {
	require('libbob/detect-os.so.php');
}

if(BOB_UNIX) {
	define('BOB_HOME',$_SERVER['HOME']);
} else {
	define('BOB_HOME',$_SERVER['APPDATA']);
}



class bobFile {

	static function safeFilename($text,$ext = null) {
		if($ext) {
			if(substr($ext,0,1) != '-') { $ext = ".{$ext}"; }
			else { $ext = preg_replace('/^-/','',$ext); }
		}		
		
		$text = str_replace(' ','',$text);		
		
		return strtolower("{$text}{$ext}");
	}
	
	static function mkdir($dir,$mode = 0777) {
		//. because the mkdir() option for recursive creation does not work
		//. on windows platforms (wtf thanks for nothing r-tards).

		$path = explode('/',$dir);
		if(BOB_UNIX && !$path[0]) { $path[0] = '/'; }
		
		$newdir = '';
		foreach($path as $subdir) {
			$newdir .= $subdir;
			if(!file_exists($newdir)) {
				mkdir($newdir,$mode);
			} $newdir .= '/';
		} return;
	}
}

?>